package org.neurone.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.neurone.session.SessionHive;
import org.neurone.session.SessionServer;
import org.neurone.session.impl.SessionHiveLocal;
import org.neurone.session.impl.SessionServerLocal;
import org.neurone.userspace.verification.Verification;

import com.opensymphony.xwork2.ActionSupport;

public class BaseActionSupport extends ActionSupport  implements ServletRequestAware{

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2992476241834933615L;
	
	protected SessionHive sessionHive;
	protected Verification verification;
	protected HttpSession httpSession;
	
	protected String target;
	
	
	public String getTarget() {
		return target;
	}


	public void setTarget(String target) {
		this.target = target;
	}


	public Verification getVerification() {
		return verification;
	}


	public void setVerification(Verification verification) {
		this.verification = verification;
	}


	protected String success(String target) {
		this.target = target;
		return SUCCESS;
	}

	protected String success() {
		this.target = "";
		return SUCCESS;
	}	
	protected String home() {
		return "home";
	}
	

	@Override
	public void setServletRequest(HttpServletRequest req) {
		this.sessionHive = new SessionHiveLocal(new SessionServerLocal(req.getSession()), this.verification);
		this.httpSession = req.getSession();
	}

	
	public SessionHive getSessionHive() {
		return sessionHive;
	}


	public void setSessionHive(SessionHive sessionHive) {
		this.sessionHive = sessionHive;
	}


	protected String checkNowSession()
	{
		return this.sessionHive.checkSession();
	}
}
